---@class jsUtil : Object
local ZZB = {}

--- 根据路径读取技能
---@param package Package
ZZB.loadSkillSkels = function(package, name)
    local path = "./packages/doublez/pkg/"..name.."/skills"
    local skels = {}
    local normalized_dir = path
        :gsub("^%.+/", "")
        :gsub("/+$", "")
        :gsub("/", ".")
    for _, filename in ipairs(FileIO.ls(path)) do
        -- 别加载下划线开头的模板技能哈
        if filename:sub(-4) == ".lua" and filename ~= "init.lua" and not filename:startsWith("_") then
        local skel = Pcall(require, normalized_dir .. "." .. filename:sub(1, -5))
            if skel then
                -- 如果返回了一个skel表
                if type(skel) == "table" and not skel.class then
                    for _, v in ipairs(skel) do
                        table.insert(skels, v)
                    end
                else
                    table.insert(skels, skel)
                end
            end
        end
    end
    package:loadSkillSkels(skels)
end

return ZZB